package algorithmTopics.link;

import java.util.Arrays;

public class test1 {

    public static void main(String[] args) {
        ListNode listNode = new ListNode(1);
        ListNode listNode1 = new ListNode(2);
        listNode.next = listNode1;
        ListNode listNode2 = new ListNode(3);
        listNode1.next = listNode2;
        int[] ints = printLink(listNode, null);
        System.out.println(Arrays.toString(ints));

        test1 test1 = new test1();
        test1.deleteNode(listNode1);
        System.out.println(Arrays.toString(printLink(listNode, null)));

    }


    public static class ListNode {
            int val;
            ListNode next;
            ListNode(int x) { val = x; }
      }

      //链表输出
    public static int[] printLink(ListNode head , int[] list ) {
        if (head.next == null) {
            return new int[] {head.val};
        }
        int[] ints = printLink(head.next, null);
        //结果集合
        int[] res = new int[ints.length + 1];
        System.arraycopy(ints,0,res,0,ints.length);
        res[ints.length] = head.val;
        return res;

    }


    private void deleteNode(ListNode node) {
        //直接把当前节点链接到下下个节点
          ListNode next = node.next;
          node.val = next.val;
          node.next = next.next;
          next.next = null;

    }

}
